package com.beyond.pm.ui.home

import com.beyond.flow.inter.UiEvent
import com.beyond.pm.base.BasicViewModel
import com.beyond.pm.bean.net.ReqLogin
import com.beyond.pm.ui.login.loginRepository
import dagger.hilt.android.lifecycle.HiltViewModel
import javax.inject.Inject

/**
 * @author chen
 * @time 2023/6/1 12:42
 * @name ProjectManage
 * @class describe
 */
@HiltViewModel
class HomeViewModel @Inject constructor() :
    BasicViewModel() {

    fun dispatch(intent: HomeUiIntent) {
        when (intent) {
            is HomeUiIntent.Test -> {
                login(intent)
            }
        }
    }

    private fun login(intent: HomeUiIntent.Test) {
        val (phone) = intent
        requestLoading({ loginRepository.postLogin(ReqLogin(username = phone, password = "1212121"))}, {})
    }
}

sealed class HomeUiIntent : UiEvent {
    data class Test(val phone: String) : HomeUiIntent()
}


